package com.pw.study.gmallpublisher.service.impl;

import com.pw.study.gmallpublisher.enties.GMVData;
import com.pw.study.gmallpublisher.mapper.GMVMapper;
import com.pw.study.gmallpublisher.service.GMVService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GMVServiceImpl implements GMVService {
    @Autowired
    private GMVMapper gmvMapper;

    @Override
    public double getOrderAmountByDate(String date) {
        Double result = gmvMapper.getGMVByDate(date);
        if(result !=null){
            return gmvMapper.getGMVByDate(date);
        }
        return 0;
    }

    @Override
    public List<GMVData> getGMVPerHourByDay(String date) {
        List<GMVData> result = gmvMapper.getGMVPerHourByDate(date);
        System.out.println(" 查询结果： "+result.toString());
        if(result.size()==0||result==null){
           result.add(new GMVData(date,0D)) ;
        }
        return result;
    }
}
